import DataColumn from './dataColumn.js'
export default class DataColumnDateTime extends DataColumn {

	//与SimpleDateFormat要求一致
	displayFormat = "yyyy-MM-dd HH:mm:ss";

	constructor (name) {
		super(name);
		
		this.setAlignment("Center");
		this.setDisplayLength(24);
	}

	getDisplayFormat() {
		return this.displayFormat;
	}

	setDisplayFormat(displayFormat) {
		this.displayFormat = displayFormat;
	}
	
	getDefaultValue() {
		let myDate = new Date()
		let year = myDate.getFullYear()
		let month = myDate.getMonth()>9?myDate.getMonth():"0"+myDate.getMonth()
		let day = myDate.getDate()>9?myDate.getDate():"0"+myDate.getDate()
		let hours = myDate.getHours()>9?myDate.getHours():"0"+myDate.getHours()
		let minutes = myDate.getMinutes()>9?myDate.getMinutes():"0"+myDate.getHours()
		let second = myDate.getSeconds()>9?myDate.getSeconds():"0"+myDate.getSeconds()
		return year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+second;
	}
	
	getDataType() {
		return "TypeDateTime";
	}
}